using System;
using System.Collections.Generic;
using System.Text;
using DDW.Collections;

namespace DDW
{
	public class InterfaceNode : BaseNode
	{
		private Modifier modifiers;
		public Modifier Modifiers
		{
			get { return modifiers; }
			set { modifiers = value; }
		}

		private IdentifierExpression name;
		public IdentifierExpression Name
		{
			get { return name; }
			set { name = value; }
		}

		private List<TypeNode> baseClasses;
		public List<TypeNode> BaseClasses
		{
			get { if (baseClasses == null) baseClasses = new List<TypeNode>(); return baseClasses; }
		}

		private NodeCollection<InterfaceMethodNode> methods;
		public NodeCollection<InterfaceMethodNode> Methods
		{
			get { if (methods == null) methods = new NodeCollection<InterfaceMethodNode>(); return methods; }
			set { methods = value; }
		}

		private NodeCollection<InterfacePropertyNode> properties;
		public NodeCollection<InterfacePropertyNode> Properties
		{
			get { if (properties == null) properties = new NodeCollection<InterfacePropertyNode>(); return properties; }
			set { properties = value; }
		}

		private NodeCollection<InterfaceIndexerNode> indexers;
		public NodeCollection<InterfaceIndexerNode> Indexers
		{
			get { if (indexers == null) indexers = new NodeCollection<InterfaceIndexerNode>(); return indexers; }
			set { indexers = value; }
		}

		private NodeCollection<InterfaceEventNode> events;
		public NodeCollection<InterfaceEventNode> Events
		{
			get { if (events == null) events = new NodeCollection<InterfaceEventNode>(); return events; }
			set { events = value; }
		}
	
		public override void ToSource(StringBuilder sb)
		{
			if (attributes != null)
			{
				attributes.ToSource(sb);
				this.NewLine(sb);
			}
			TraceModifiers(modifiers, sb);

			sb.Append("interface ");
			name.ToSource(sb);
			sb.Append(" ");

			if (baseClasses != null && baseClasses.Count > 1)
			{
				sb.Append(": ");
				string comma = "";
				foreach (TypeNode bcls in baseClasses)
				{
					sb.Append(comma);
					comma = ", ";
					bcls.ToSource(sb);
				}
			}

			this.NewLine(sb);
			sb.Append("{");
			indent++;
			this.NewLine(sb);

			if (properties != null)
			{
				properties.ToSource(sb);
			}
			if (methods != null)
			{
				methods.ToSource(sb);
			}
			if (indexers != null)
			{
				indexers.ToSource(sb);
			}
			if (events != null)
			{
				events.ToSource(sb);
			}

			indent--;
			this.NewLine(sb);
			sb.Append("}");
			this.NewLine(sb);

		}
	}
}